//
//  ViewController.m
//  CQFramework
//
//  Created by Martin on 16/5/21.
//  Copyright © 2016年 caoqin. All rights reserved.
//

#import "ViewController.h"
#import "CQCommonHeader.h"
#import "CQURL.h"
#import "showInfo.h"
#import "CQAFNetHelper.h"
#import "RNBlurModalView.h"
#import "TYDotIndicatorView.h"
#import "AppDelegate.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kWhiteColor;
    self.title = [NSString stringWithFormat:@"%ld",self.navigationController.viewControllers.count];
    NSLog(@"%@",[CQCommon cqGetSerialNumberString:@"234"]);
}


/**测试网络连接*/
-(void)test2{
    
    UIButton *btn = [CQButtonFactory cqCommButton];
    [btn addTarget:self action:@selector(test2click) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
}

-(void)test2click{
    
    if ([CQCommon cqIsConnectNetwork]) {
        NSLog(@"有网络连接");
    }else{
        NSLog(@"没有网络连接");
    }
    
}

/**测试导航栏返回手势*/
-(void)test1{
    self.navigationItem.leftBarButtonItem = [CQNavigationItemFactory cqNavItemWithImgage:[UIImage new] Targed:self Action:@selector(backBtn) Size:CGSizeMake(30, 30)];
    
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(100, 100, 100, 100);
    btn.backgroundColor = kRedColor;
    [btn addTarget:self action:@selector(nextbtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
}

-(void)backBtn{
    NSLog(@"33");
}

-(void)nextbtnClick{
    
    [self.navigationController pushViewController:[ViewController new] animated:YES];
    
}

-(void)testTYDotView{
    TYDotIndicatorView *tyView = [[TYDotIndicatorView alloc]initWithFrame:CGRectMake(100, 100, 200, 20) dotStyle:TYDotIndicatorViewStyleCircle dotColor:kOrangeColor dotSize:CGSizeMake(10, 10)];
    tyView.backgroundColor = [UIColor redColor];
    [self.view addSubview:tyView];
    [tyView startAnimating];
}

-(void)testCQAFHelper{
    
    NSMutableDictionary * dic=[NSMutableDictionary dictionary];
    [dic setObject:[CQURL ToJson:@"admin"] forKey:@"userID"];
    [dic setObject:[CQURL ToJson:@"8888888"] forKey:@"password"];
    [dic setObject:[CQURL ToJson:@"ios"] forKey:@"osType"];
    [dic setObject:[CQURL ToJson:@"0"] forKey:@"tokenID"];
    [dic setObject:@"Login_User_iOS" forKey:@"svcName"];
    showInfo *infoShow = [CQURL showLoding:@"请稍候..." TargetView:self.view];
    [[CQAFNetHelper sharInstance]cqPostparams:dic CompletionBlock:^(responseResult *reslut) {
        //隐藏加载框
        [CQURL hideLoading:infoShow];
        if (!reslut.isCorrect)
        {
            [self.view makeToast:kGetLocakString(@"network_exection")];
            return;
        }
        if (reslut.flag==FAILED) {
            [self.view makeToast:reslut.erroMessage];
            return;
        }
    self.view.backgroundColor = kOrangeColor;
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    button.frame = CGRectMake(100, 100, 100, 100);
    button.backgroundColor = kWhiteColor;
    [button addTarget:self action:@selector(btnclick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    }];
}

- (void) btnclick{
    
    [UIView animateWithDuration:0.3 animations:^{
        
      AppDelegate *delegate =  [UIApplication sharedApplication].delegate;
        delegate.window.alpha = 0.3;
        delegate.window.frame = CGRectMake(0, kScreenHeight/2, kScreenWidth, 0);
        
    }completion:^(BOOL finished) {
        exit(0);
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
